home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 016 / 26time11.arc / MACROS.ASM < prev   
Encoding:
Assembly Source File  |  1986-11-28  |  4.5 KB  |  140 lines

  1. ;;---------------------------------------------------------------------------
  2. ;;--------------------                                 ----------------------
  3. ;;--------------------  IFR CONDITION <INSTRUCTIONS>   ----------------------
  4. ;;--------------------                                 ----------------------
  5. ;;---------------------------------------------------------------------------
  6.  
  7.                        
  8. IFR    MACRO    CONDITION, INSTRUCTIONS
  9. LOCAL    DO, DONT               
  10.     J&CONDITION SHORT DO           
  11.     JMP SHORT DONT               
  12. DO:    INSTRUCTIONS
  13. DONT:            
  14.     ENDM        
  15.  
  16.  
  17. ;; CONDITION may be any valid condition of the conditional JMP instruction.
  18. ;; i.e. A, AE, B, BE, C, E, G, GE, L, LE, NA, NAE, NB, NBE, NC, NE, NG,
  19. ;;      NGE, NL, NLE, NO, NP, NS, NZ, O, P, PE, PO, S, Z, CXZ.
  20. ;; 
  21. ;; <INSTRUCTIONS> are any valid assembly instructions.  i.e. <jmp label>,
  22. ;; <mov reg, value>, <int xx>, etc.  The left and right arrows are required.
  23. ;;
  24. ;; If an invalid condition is used, you will receive a SYNTAX ERROR for the
  25. ;; source line responsible.  If an invalid instruction is used, you will 
  26. ;; receive whatever ERROR is appropriate, on the source line responsible.
  27. ;;
  28. ;;
  29. ;; This macro is useful for writing structured assembler code.  If you 
  30. ;; have ever written the following type of code, this macro is for you:
  31. ;; 
  32. ;;          TST   AX, 0FFh
  33. ;;          JNE   G1
  34. ;;          JMP   G2
  35. ;; G1:      MOV   AX, 0FF01h
  36. ;; G2:      more code. . .
  37. ;; 
  38. ;; With my macro installed, this could be re-written:
  39. ;;
  40. ;;          TST   AX, 0FFh
  41. ;;          IFR NE <mov AX, 0FF01h>
  42. ;;
  43. ;; You need not worry about naming a label, and you save a line of source,
  44. ;; besides making your program more readable.  It is useful when you need
  45. ;; to make a conditional jump of more than +/- 128 bytes.
  46. ;;
  47. ;;          TST   AX, 0FFh
  48. ;;          JNZ   G1:
  49. ;;          JMP   ISZERO
  50. ;; G1:      more code. . .
  51. ;; 
  52. ;; With my macro installed, this could be re-written:
  53. ;;
  54. ;;          TST   AX, 0FFh
  55. ;;          IFR Z <jmp iszero>
  56. ;;
  57. ;; Again, it is much easier to write and read.  For your information, it 
  58. ;; would assemble like this:
  59. ;;
  60. ;;          JZ    ??0001
  61. ;;          JMP   ??0002
  62. ;; ??0001:  JMP   ISZERO
  63. ;; ??0002:
  64. ;;
  65. ;; Each time the macro is called, different numbers are used for the macros.
  66. ;; Have fun!
  67. ;;
  68. ;;---------------------------------------------------------------------------
  69. ;;---------------------------------------------------------------------------
  70. ;;---------------------------------------------------------------------------
  71. ;;---------------------------------------------------------------------------
  72.  
  73.  
  74.  
  75.  
  76. ;;---------------------------------------------------------------------------
  77. ;;------------------------------             --------------------------------
  78. ;;------------------------------   PUSHALL   --------------------------------
  79. ;;------------------------------             --------------------------------
  80. ;;---------------------------------------------------------------------------
  81.  
  82.                        
  83. PUSHALL    macro
  84.  
  85.     push    ax        ; Save all the registers and the flags.
  86.     push    bp
  87.     push    bx
  88.     push    cx
  89.     push    di
  90.     push    ds
  91.     push    dx
  92.     push    es
  93.     push    si
  94.     pushf
  95.  
  96.     ENDM        
  97.  
  98.  
  99. ;;  This macro saves all the registers and flags.
  100. ;;
  101. ;;---------------------------------------------------------------------------
  102. ;;---------------------------------------------------------------------------
  103. ;;---------------------------------------------------------------------------
  104. ;;---------------------------------------------------------------------------
  105.  
  106.  
  107.  
  108.  
  109. ;;---------------------------------------------------------------------------
  110. ;;------------------------------            ---------------------------------
  111. ;;------------------------------   POPALL   ---------------------------------
  112. ;;------------------------------            ---------------------------------
  113. ;;---------------------------------------------------------------------------
  114.  
  115.                        
  116. POPALL    macro
  117.  
  118.     popf              ; restore all the registers and flags
  119.     pop    si
  120.     pop    es
  121.     pop    dx
  122.     pop    ds
  123.     pop    di
  124.     pop    cx
  125.     pop    bx
  126.     pop    bp
  127.     pop    ax
  128.  
  129.     ENDM        
  130.  
  131.  
  132. ;;  This macro restores all the registers and flags.
  133. ;;
  134. ;;---------------------------------------------------------------------------
  135. ;;---------------------------------------------------------------------------
  136. ;;---------------------------------------------------------------------------
  137. ;;---------------------------------------------------------------------------
  138.  
  139.  
  140.